package crack.lshape;

import java.io.IOException;

import math2.MathUtilities;
import crack.AbstractLshapeConstantCrack;
import fem2.Mesh;
import fem2.MeshUtilities;
import fem2.mesh_and_topology.LineSpatialCriteria;
import fem2.mesh_and_topology.SpatialCriteria;
import fem2.pre_and_post.PatchMeshGenerator;

/**
 * Lshape with structured quadrilateral mesh
 * 
 * @author hbui
 * 
 */
public class LshapeQuadMeshConstantCrack extends AbstractLshapeConstantCrack {

	public LshapeQuadMeshConstantCrack() {
		meshFileName = "structured-quad-mesh.msh";
	}

	@Override
	public Mesh createMesh() {
		PatchMeshGenerator p1 = new PatchMeshGenerator(41, 21, 0, 0, 25, 25);
		Mesh mesh1 = p1.getMesh(2);

		PatchMeshGenerator p2 = new PatchMeshGenerator(21, 21, 0, 500, 25, 25);
		Mesh mesh2 = p2.getMesh(2);

		SpatialCriteria c = new LineSpatialCriteria(0, 500, 1, 0);

		mesh1 = MeshUtilities.joinMesh(mesh1, mesh2, c);

		return mesh1;
	}

	public static void main(String[] args) throws IOException {

		AbstractLshapeConstantCrack Lshape = new LshapeQuadMeshConstantCrack();

		double[] lambda = MathUtilities.createLambdaArray(11.22, 0.5, 12);

		// double[] lambda = MyLinAlg.createLambdaArray(11.22, 0.5, 25, 0.1,
		// 30);

		Lshape.run(lambda);

	}

}
